package com.makefuture.utils.ewm;
/**
 * 杜建阳  2016-04-07
 * 一维码生成  成功
 */
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;

import org.jbarcode.JBarcode;
import org.jbarcode.encode.EAN8Encoder;
import org.jbarcode.paint.EAN8TextPainter;
import org.jbarcode.paint.WidthCodedPainter;
import org.jbarcode.util.ImageUtil;

public class OneBarcodeUtil {


	 public static void main(String[] paramArrayOfString) {  
	        try {  
	            JBarcode localJBarcode = new JBarcode(EAN8Encoder.getInstance(),
	            		WidthCodedPainter.getInstance(),EAN8TextPainter.getInstance());  
	            String str = "445566";  
	            BufferedImage localBufferedImage = localJBarcode.createBarcode(str);  
	            saveToJPEG(localBufferedImage, "EAN8.jpg");
	        }  
	        catch (Exception localException) {  
	            localException.printStackTrace();  
	        }  
	    }  

	    static void saveToJPEG(BufferedImage paramBufferedImage, String paramString) {  
	        saveToFile(paramBufferedImage, paramString, "jpeg");  
	    }  

	    static void saveToFile(BufferedImage paramBufferedImage, String paramString1, String paramString2) {  
	        try {  
	            FileOutputStream localFileOutputStream = 
	            	new FileOutputStream("C:/Users/dujianyang/Desktop/" + paramString1);  
	            ImageUtil.encodeAndWrite(paramBufferedImage, paramString2, localFileOutputStream, 96, 96);  
	            localFileOutputStream.close();  
	        }catch (Exception localException) {  
	            localException.printStackTrace();  
	        }  
	    }  
}
